package org.finesys.auth.controller;


import cn.hutool.core.lang.Dict;
import lombok.RequiredArgsConstructor;
import org.finesys.common.core.module.R;
import org.finesys.common.security.client.properties.GiteeProperties;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
@RequestMapping("/configuration")
public class ConfigurationEndpoint {

    private final ObjectProvider<GiteeProperties> giteePropertiesObjectProvider;

    @GetMapping
    public R<?> configuration() {
        Dict dict = Dict.create();
        giteePropertiesObjectProvider.ifAvailable(giteeProperties -> dict.put("giteeAppid", giteeProperties.getDefaultAppId()));
        return R.success(dict);
    }
}
